﻿using FinalWork.Model.EF;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity.Validation;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace FinalWork
{


    internal static class Program
    {

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
    internal class manuServices
    {
        
        /// <summary>
        /// 获得所有数据
        /// </summary>
        /// <returns></returns>
        public List<manu> GetAll()
        {
            var db = new FinalWorkEntities4();
            return db.manu.ToList();
        }


        /// <summary>
        /// 删除记录
        /// </summary>
        /// <param name="id"></param>
        public void Delete(Guid id)
        {
            var db = new FinalWorkEntities4();
            var item = db.manu.Find(id);
            if (item != null)
            {
                db.manu.Remove(item);
                db.SaveChanges();
            }
        }



        /// <summary>
        /// 根据Id，获得指定记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public manu GetById(Guid id)
        {
            var db = new FinalWorkEntities4();
            return db.manu.Find(id);
        }

        /// <summary>
        /// 修改记录
        /// </summary>
        /// <param name="model"></param>
        public void Edit(manuEditModel model)
        {
            var db = new FinalWorkEntities4();
            var item = db.manu.Find(model.Id);
            if (item != null)
            {
                item.菜名 = model.菜名;
                item.份数 = model.份数;
                item.价格 = model.价格;

            }
            db.SaveChanges();
        }
    }

    internal class manuServices01
    {
        
        /// <summary>
        /// 加菜菜单
        /// </summary>
        /// <returns></returns>
        public List<manuAdd> GetAll01()
        {
            var db = new FinalWorkEntities4();
            return db.manuAdd.ToList();
        }

        /// <summary>
        /// 新建记录
        /// </summary>
        /// <param name="model"></param>
        public void Create(manuAddCreateModel model)
        {
            var db = new FinalWorkEntities4();
            var newItem = new manuAdd()
            {
                Id = Guid.NewGuid(),
                菜名 = model.菜名,
                份数 = model.份数,
                价格 = model.份数

            };
            db.manuAdd.Add(newItem);
            db.SaveChanges();
        }

        /// <summary>
        /// 删除记录
        /// </summary>
        /// <param name="id"></param>
        public void Delete(Guid id)
        {
            var db = new FinalWorkEntities4();
            var item = db.manuAdd.Find(id);
            if (item != null)
            {
                db.manuAdd.Remove(item);
                db.SaveChanges();
            }
        }


    }



    /// <summary>
    /// 新增模型
    /// </summary>
    internal class manuCreateModel
    {
        public string 菜名 { get; set; }
        public string 份数 { get; set; }
        public string 价格 { get; set; }


    }


    /// <summary>
    /// 新增模型Add
    /// </summary>
    internal class manuAddCreateModel
    {
        public string 菜名 { get; set; }
        public string 份数 { get; set; }
        public string 价格 { get; set; }


    };

    /// <summary>
    /// 修改模型
    /// </summary>
    internal class manuEditModel : manu
    {
    }

   
}
    
   







      
